package com.yzy.util.response;

import lombok.Getter;
import org.springframework.http.HttpStatus;

import java.util.Arrays;

@Getter
public class ResponseObj {
    private final HttpStatus status;
    private final Object data;
    private final String message;

    /**
     * 执行成功返回的实体信息
     *
     * @param status
     * @param message
     * @param data
     */
    public ResponseObj(HttpStatus status, String message, Object data) {
        this.status = status;
        this.data = data;
        this.message = message;
    }

    /**
     * 执行失败返回的实体信息
     *
     * @param status
     * @param data
     * @param message
     */
    public ResponseObj(HttpStatus status, String message, Object... data) {
        this.status = status;
        if (data != null) this.data = Arrays.asList(data).toString();
        else this.data = null;
        this.message = message;
    }
}